<?php
	// figure out number of groups to check members of
	$query = "SELECT * FROM n_monitor";
	$result = mysql_query($query);
	$num_rows = mysql_num_rows($result);
	if(strlen($num_rows) == 0) {
		$num_rows = 1;
	}

	// add new task
	$data = "cmd=task_add\n";
	$network->send($data);
	while($from = $network->recv()) {
		if(strpos($from, "task_add_reply") !== false) {
			break;
		}
	}
	$pm->init($from, "|");
	$task_id = $pm->get("id");

	// set details of new task
	$network->send("cmd=task_set|id=$task_id|data=todo|value=monitor\n");
	$network->send("cmd=task_set|id=$task_id|data=todo_count|value=$num_rows\n");
	$network->send("cmd=task_set|id=$task_id|data=block_size|value=8\n");
	$network->send("cmd=task_set|id=$task_id|data=timeout|value=120\n");
	$network->send("cmd=task_set|id=$task_id|data=db_user|value=dispatch\n");
	$network->send("cmd=task_set|id=$task_id|data=db_pass|value=dispatchpw\n");
	$network->send("cmd=task_set|id=$task_id|data=db_name|value=dispatch\n");
	$network->send("cmd=task_set|id=$task_id|data=db_host|value=$server_mysql\n");
	$network->send("cmd=task_set|id=$task_id|data=db_port|value=3306\n");

	$network->send("cmd=task_start|id=$task_id\n");
?>
